<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

$worker = new GearmanWorker();
$worker->addServer();
$worker->addFunction('syncToRedis', 'syncToRedis');
 
$redis = new Redis();
$redis->connect('115.28.100.99', 6379);
echo("begin:\n");
 
while($worker->work());
function syncToRedis($job)
{
        global $redis;
        $workString = $job->workload();
        $work = json_decode($workString);
        echo('get value:');
        echo($workString);
        echo("\n");
        echo('json_decode:');
        var_dump($work);
        echo("\n");
        if(!isset($work->user_id)){
                return false;
        }
        $redis->set($work->user_id, $workString);
}
